/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.com.digitalnet.ad.base;

import java.util.Date;

import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;

import org.apache.solr.client.solrj.beans.Field;
import org.springframework.format.annotation.DateTimeFormat;

import cn.com.digitalnet.ad.entity.User;

@MappedSuperclass
public abstract class IdEntity {
	@Field
	protected Long id;
	
	protected Date addTime;
	protected User addUser;
	@DateTimeFormat(pattern="yyyy-MM-dd") protected Date updateTime;
	@DateTimeFormat(pattern="yyyy-MM-dd") protected User updateUser;

	protected Integer isenabled;
	protected Integer isdeleted;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	// JPA 基于add_user列的多对一关系定义
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "add_user")
	public User getAddUser() {
		return addUser;
	}

	public void setAddUser(User addUser) {
		this.addUser = addUser;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	// JPA 基于update_user列的多对一关系定义
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name = "update_user")
	public User getUpdateUser() {
		return updateUser;
	}

	public void setUpdateUser(User updateUser) {
		this.updateUser = updateUser;
	}

	public Integer getIsenabled() {
		return isenabled;
	}

	public void setIsenabled(Integer isenabled) {
		this.isenabled = isenabled;
	}

	public Integer getIsdeleted() {
		return isdeleted;
	}

	public void setIsdeleted(Integer isdeleted) {
		this.isdeleted = isdeleted;
	}
	
}
